package com.oscarmovie.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.oscarmovie.Constants;
import com.oscarmovie.model.Country;
import com.oscarmovie.model.Datetime;
import com.oscarmovie.service.CountryService;
import com.oscarmovie.service.DatetimeService;

public class DatetimeAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private DatetimeService datetimeService;
	private CountryService countryService;
	private Datetime datetime;
	private List<Datetime> datetimes;
	private List<Country> countries;


	public String execute() throws Exception {
		throw new Exception("Please specify method name!");
	}

	public String save() throws Exception {
		datetimeService.save(datetime);
		return edit();
	}

	public String load() throws Exception {
		this.setDatetime(datetimeService.load(datetime.getId()));
		return SUCCESS;
	}
	public String add() throws Exception {
		setDatetime(null);
		return Constants.ADD;
	}
	public String edit() throws Exception {
		loadAll();
		load();
		return Constants.EDIT;
	}
	public String loadAll() throws Exception {
		this.datetimes = datetimeService.loadAll();
		return SUCCESS;
	}
	public String select() throws Exception {
		loadAll();
		return Constants.SELECT;
	}
	public List<Datetime> getDatetimes() {
		return datetimes;
	}

	public void setDatetimeService(DatetimeService datetimeService) {
		this.datetimeService = datetimeService;
	}

	public void setDatetime(Datetime datetime) {
		this.datetime = datetime;
	}

	public Datetime getDatetime() {
		return datetime;
	}

	public void setCountries(List<Country> countries) {
		this.countries = countries;
	}

	public List<Country> getCountries() {
		return countries;
	}

	public void setCountryService(CountryService countryService) {
		this.countryService = countryService;
	}

	public CountryService getCountryService() {
		return countryService;
	}



}
